﻿<script type="text/javascript">
    //获取填写所有值
    function ApplyModel() {
        var obj = new Object();       
        obj.ApplyTime = $("#ApplyTime").datetimebox('getValue');
        obj.ApplyCount = $("#ApplyCount").numberbox('getText');
        obj.Remark1 = $("#Remark").textbox('getText');
        return obj;
    }
    //新增申请发票
    function initApply() {
        $("#ApplyPerson").textbox("setText", '@ViewData["Name"]');
        $.InitControlDateTime("#ApplyTime");
        //$.initTextBoxNum('#ApplyCount', "请填写发票数量", true);
        $("#ApplyCount").numberbox("clear");
        $("#Remark").textbox("clear");
    }
    //提交方法
    function submitApplyDetailForm() {
        var isValid = $("#ApplyDetailList").form("validate");
        if (isValid) {
                $.messager.confirm('提示', '确认申请吗?', function (r) {
                    if (r) {
                        $.ajax({
                            type: 'POST',
                            url: '@Url.Content("~/IM/I_InvoiceApply/SaveApply")',
                        data:
                            {
                                CenterCode: '@ViewData["CenterID"]',
                                StationCode:'@ViewData["StationID"]',
                                ApplyUserID: '@ViewData["UserID"]',  
                                ApplyUserName: '@ViewData["Name"]',
                                sApplyInfo: JSON.stringify(ApplyModel())
                            },
                        dataType: "json",
                        success: function (jsData) {
                            $.handleJsonResult(jsData, function () {
                                $('#ApplyDetailList').dialog("close");
                                $("#gridApplyList").datagrid("reload");
                            })
                        }
                    });
                    } else { $('#btnApply').linkbutton('enable'); }
            });
        }
        else {
            $.showMsg("请填写必填项！", "提示");
        }
    }

</script>
<div id="ApplyDetailList" class="easyui-dialog" title="申领发票页面" data-options="modal:true,collapsible:false,minimizable:false,maximizable:false,closed:true,resizable:false,iconCls:'icon-custom-cGoodsFull'" style="width:640px;height:255px;padding:10px;">  
    <table border="0" cellpadding="0" cellspacing="10" style="width: 99%; margin-left: 0px; margin-right: 0px; margin-top: 10px; margin-bottom: 0px">
        <tr>
            <td width="120px" style="text-align:right">申领时间：</td>
            <td>
                <input id="ApplyTime" class="easyui-datetimebox" style="width:150px" data-options="required:true" />
            </td>
            <td width="120px" style="text-align: right">申领人：</td>
            <td><input id="ApplyPerson" class="easyui-textbox" style="width:150px" data-options="readonly:true" /></td>
        </tr>
        <tr>
            <td width="120px" style="text-align:right">申领数量：</td>
            <td>
                <input id="ApplyCount" class="easyui-numberbox" style="width:150px" data-options="required:true" /> 张
            </td>
        </tr>
        <tr>
            <td width="100px" style="text-align:right">备注：</td>
            <td colspan="4">
                <input id="Remark" class="easyui-textbox" data-options="multiline:true" style="width:470px;height:50px">
            </td>
        </tr>
        <tr></tr>
        <tr></tr>
        <tr>
            <td colspan="4" style="text-align:center">
                <a href="javascript:void(0)" id="btnApply" class="easyui-linkbutton" data-options="iconCls:'icon-custom-cDelivery'" onclick="submitApplyDetailForm()">&nbsp;&nbsp;确认申领&nbsp;&nbsp;</a>
                &nbsp;&nbsp;
            </td>
        </tr>
    </table>
</div>